/**
 * Copyright (C) 2011 Andrew C. Love (DNC) <dnc.app.sup@gmail.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.dnc.cloak.framework.persistence;

import java.util.ArrayList;
import java.util.List;

public class CrudResult <T> {
	
	private int numDelete   = 0;
    private int numSelect   = 0;
    private int numUpdate   = 0;
    private int numInsert   = 0;
    private List<T> result;
    
    /**
     * @return the result object
     */
    public T getFirstResult() {
    	
    	if (result!=null && result.size() > 0) {
    		return result.get(0);
    	}
    	else{
    		return null;
    	}
        
    }

    /**
     * @return the resultlist
     */
    public List<T> getResult() {
        return result;
    }
    /**
     * @param result the result to set
     */
    public void setResult(List<T> result) {
        this.result = result;
    }

    /**
     * @param result the result to set
     */
    public void setResult(T result) {
        this.result = new ArrayList<T>();
        this.result.add(result);
    }
    /**
     * @return the numDelete
     */
    public int getNumDelete() {
        return numDelete;
    }
    /**
     * @param numDelete the numDelete to set
     */
    public void setNumDelete(int numDelete) {
        this.numDelete = numDelete;
    }
    /**
     * @return the numSelect
     */
    public int getNumSelect() {
        return numSelect;
    }
    /**
     * @param numSelect the numSelect to set
     */
    public void setNumSelect(int numSelect) {
        this.numSelect = numSelect;
    }
    /**
     * @return the numUpdate
     */
    public int getNumUpdate() {
        return numUpdate;
    }
    /**
     * @param numUpdate the numUpdate to set
     */
    public void setNumUpdate(int numUpdate) {
        this.numUpdate = numUpdate;
    }
    /**
     * @return the numInsert
     */
    public int getNumInsert() {
        return numInsert;
    }
    /**
     * @param numInsert the numInsert to set
     */
    public void setNumInsert(int numInsert) {
        this.numInsert = numInsert;
    }
    /* (non-Javadoc)
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuilder builder = new StringBuilder();
        builder.append("CrudResult [getNumDelete()=");
        builder.append(getNumDelete());
        builder.append(", getNumInsert()=");
        builder.append(getNumInsert());
        builder.append(", getNumSelect()=");
        builder.append(getNumSelect());
        builder.append(", getNumUpdate()=");
        builder.append(getNumUpdate());
        builder.append(", getResult()=");
        builder.append(getResult());
        builder.append("]");
        return builder.toString();
    }       

}
